// 定义模块，加载头部与尾部，实现资源复用
define(["jquery"],function($){
  function HeaderAndFooter(){
    this.init();
  }
  HeaderAndFooter.prototype={
    constructor:HeaderAndFooter,
    init() {
      this.loadHeader();
      this.loadFooter();
    },

    // ============加载头部资源
    loadHeader(){
      $("header").load("/html/include/header.html",function(){
        // =============显示隐藏商品列表
        var btn = document.getElementById("all_title");
        console.log(btn);
        btn.onclick = function(){
          // document.getElementById("all_selects").style.display="block";
          if(document.getElementById("all_selects").style.display==="block"){
            document.getElementById("all_selects").style.display="none";
          }else {
            document.getElementById("all_selects").style.display="block"
          }
        }


        // ===============滚动广告
        var _top = document.getElementById("rotate_advise").style.top;
        var timer = setInterval(function(){
          if(_top<-260){
            document.getElementById("rotate_advise").style.top=0;
            _top=0;
          }else {
            document.getElementById("rotate_advise").style.top=_top+"px";
            _top -= 52;
          }
        },1000);
      });

        // this.addListener();
    },
    // ===========加载尾部资源
    loadFooter(){
      $("footer").load("/html/include/footer.html");
      console.log("sadaf");
    }
  }

  // ===========创建对象，并返回
  return new HeaderAndFooter();
});
